package com.example.dict.ativities;

import android.os.Bundle;

import com.example.dict.R;
import com.example.dict.bean.pinbuWordBean;
import com.example.dict.db.DBManager;
import com.example.dict.utils.ApiUtil;
import com.example.dict.utils.CommonUtil;

import java.util.List;


public class QueryBushouActivity extends BaseSearchActivity {

    String Url;//获取部首对应的文字网址

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mTitleTv.setText(R.string.main_bushou);
        initData(CommonUtil.FILE_BUSHOU,CommonUtil.TYPE_BUSHOU);
        setExLvListenr(CommonUtil.TYPE_BUSHOU);
        mExpandableListView.expandGroup(0);

        Word = "丨";
        Url = ApiUtil.getBushouurl(Word,Page,PageSize);
        //加载数据
        loadData(Url);
        setGVListener(CommonUtil.TYPE_BUSHOU);//下拉刷新，上拉加载
    }

    /**
     * 网络获取数据失败时会调用
     * 注意：拼音查询和部首查询获取的方法分开写，所以onError方法写到子类中
     * @param ex
     * @param isOnCallback
     */

    @Override
    public void onError(Throwable ex, boolean isOnCallback) {
        List<pinbuWordBean.ResultBean.ListBean> list = DBManager.queryBsWordFromPyWord(Word,Page,PageSize);
        refreshDataByGv(list);

    }
}
